console.log("initer_running")
$.ajaxSetup({
  async: false
})
$.getJSON("/articlelist/index.json", (data) => {
      var indexlist = data["data"]
      console.log(indexlist)
      document.getElementById("archiveCount").innerText = indexlist.length
      sortedlist=[]
      for (const key in indexlist) {
        if (Object.hasOwnProperty.call(indexlist, key)) {
          const articalorigin = indexlist[key];
          sortedlist.push(articalorigin)
        }
      }
      sortedlist.sort((a,b)=>a.createtime>b.createtime)
      console.log(sortedlist)
      for (let index = 0; index < sortedlist.length; index++) {
        const articalorigin = sortedlist[index];
          $.getJSON(articalorigin["origin"], (data) => {
              $.get(data["data"].body, (body) => {
                document.getElementById("posts-expand").insertAdjacentHTML("beforeend",
                  `
<article itemscope itemtype="http://schema.org/Article" class="post-block home" lang="zh-CN">

  <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="image" content="/images/avatar.jpg">
    <meta itemprop="name" content="Zhengjiabao">
    <meta itemprop="description" content="">
  </span>

  <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="ZhengJiabao's Blog">
  </span>
    <header class="post-header">
      <h2 class="post-title" itemprop="name headline">
        
          <a href="/articledetail/?${data["data"].hash}" class="post-title-link" itemprop="url">${data["data"].headline}</a>
      </h2>

      <div class="post-meta">
          <span class="post-meta-item">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            

            <time itemprop="dateCreated datePublished" datetime="${data["data"].datePublishedtime}">${data["data"].datePublished}</time>
          </span>

        

      </div>
    </header>


  <div class="post-body" itemprop="articleBody"> 
  ${body}  
  </div>
  <div>
  </div>
    <footer class="post-footer">
      <div class="post-eof"></div>
    </footer>
</article>
`

                )
              })
            })
            
          }
      }) 
    $.ajaxSetup({
      async: true
    })

    function localstoragerenewer() {
      $.ajaxSetup({
        async: false
      })
      $.getJSON("/articlelist/index.json", (data) => {
        demandfrom = localStorage.getItem("__zitem__zarticlepackage_demandfrom") || {
          "data": []
        }
        for (const key in data["data"]) {
          if (Object.hasOwnProperty.call(data["data"], key)) {
            const element = data["data"][key];
            if ((!Object.hasOwnProperty.call(demandfrom["data"], key)) || demandfrom["data"][key]["timestamp"] != data["data"][key]["timestamp"]) {
              $.getJSON(element["origin"], (detail) => {

              })
            }
          }
        }
      })
      $.ajaxSetup({
        async: true
      })
    }